﻿<UserControl x:Class="ReporterControlLibrary.EvaluatePath"
	        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:rcl="clr-namespace:ReporterControlLibrary"
            xmlns:converters="clr-namespace:ReporterControlLibrary.Converters" 
            xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
            mc:Ignorable="d" 
            d:DesignHeight="600" d:DesignWidth="600">
    <UserControl.Resources>
        <converters:StringLengthToVisibilityConverter x:Key="ErrorMsgVisibilityConverter" SourceValue="0" MatchVisibility="Collapsed" MisMatchVisibility="Visible" />
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="35"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="36.04"/>
            <ColumnDefinition/>
            <ColumnDefinition Width="141.056"/>
            <ColumnDefinition Width="122.944"/>
        </Grid.ColumnDefinitions>
        <TextBox x:Name="PathBox" KeyUp="PathBox_KeyUp" Text="{Binding Path=EvalExpression, Mode=TwoWay, UpdateSourceTrigger=Explicit}" TextChanged="PathBox_TextChanged" VerticalAlignment="Center" Grid.Column="1" Margin="0" Grid.ColumnSpan="2"/>
        <TextBlock TextWrapping="Wrap" HorizontalAlignment="Right" Margin="0,0,5,0" VerticalAlignment="Center" Text="Path" Style="{DynamicResource FormLabelStyle}"/>
        <TextBlock TextWrapping="Wrap" Visibility="{Binding Path=ErrorMessage, Converter={StaticResource ErrorMsgVisibilityConverter}}" Grid.Row="1" HorizontalAlignment="Right" Margin="0,0,5,0" VerticalAlignment="Top" Text="Error" Style="{DynamicResource FormLabelStyle}"/>
        <TextBlock TextWrapping="Wrap" Grid.Row="1" Grid.Column="1"  Margin="0" VerticalAlignment="Center" Text="{Binding Path=ErrorMessage}" Visibility="{Binding Path=ErrorMessage, Converter={StaticResource ErrorMsgVisibilityConverter}}" Foreground="{DynamicResource ErrorMsgBrush}" Style="{DynamicResource FormLabelStyle}" Grid.ColumnSpan="2"/>
        <Button x:Name="EvaluatePath_bt" Click="EvaluatePathBtClick" Content="Eval" Grid.Column="3" Height="25" Margin="5,0.7">
            <!--<i:Interaction.Triggers>
                <i:EventTrigger  x:Name="evaltrigger" >
                    <i:InvokeCommandAction  Command="{Binding EvaluatePathCommand, Mode=OneWay, Source={StaticResource ApplicationManager}}" CommandParameter="{Binding Project, Mode=OneWay}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>-->
        </Button>
        <rcl:InstanceTree x:Name="EvalModelTree" DataContext="{Binding Path=EvalResult}" Grid.Row="2" d:LayoutOverrides="Width" Grid.ColumnSpan="2" TreeBackground="{DynamicResource ControlDarkOpaqueBrushKey}"/>
        <rcl:EvaluatePathToolbox DataContext="{Binding}" Grid.Column="2" HorizontalAlignment="Left" Grid.Row="2" VerticalAlignment="Top" Grid.ColumnSpan="2" Loaded="EvaluatePathToolbox_Loaded" />
    </Grid>
</UserControl>
